package com.gzy.blog.sys.dao.impl;

import java.util.Date;

import org.springframework.stereotype.Repository;

import com.gzy.blog.common.BaseDao;
import com.gzy.blog.sys.dao.LogDao;
import com.gzy.blog.sys.entity.Log;

@Repository
public class LogDaoImpl extends BaseDao<Log, Integer> implements LogDao {

    // @Override
    @Override
    public void addLog() {
        // service层做事务，Dao层返回Exception?还是RuntimeException？
        // RuntimeException
        // System.out.println(1 / 0);
        // if (true) {
        // throw new Exception();
        // }
        try {
            Log log = new Log();
            log.setLog("新增了一个用户");
            log.setCreateTime(new Date());
            log.setUserId(1);
            save(log);
            System.out.println("Log added!");
        } catch (Exception e) {
            throw new RuntimeException();
        }
    }
}
